package com.example.springboottest.util;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

@Slf4j
public class LogStashUtil {
    static final Logger logger = LoggerFactory.getLogger("LOGSTASH");

    public static void sendMessage(String username, String type, String content,
                                   Date createTime, String parameters) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("username", username);
        jsonObject.put("type", type);
        jsonObject.put("content", content);
        jsonObject.put("parameters", parameters);
        jsonObject.put("createTime", createTime);
        logger.info(jsonObject.toString());
    }
}
